package dao;

import java.sql.*;
import java.util.*;
import to.TipoDocumentoTO;

public class TipoDocumentoDAO extends GenericDAO{
    public TipoDocumentoDAO(Transaction transacction) {
	super(transacction);
    }
    
    @SuppressWarnings("unchecked")
    public List<TipoDocumentoTO> listarDocumentos() throws TransactionException {
        Connection conn;
        List<TipoDocumentoTO> list = new ArrayList();
        try {
            conn = (Connection) t.getConnection();
            String sqlCall = "{call uspListarTipoDocumentos}";
            CallableStatement procedure = conn.prepareCall(sqlCall);
            ResultSet rs = procedure.executeQuery();

            while (rs.next()) {
                int j=0;
                TipoDocumentoTO vo = new TipoDocumentoTO(); 
                vo.setCTipoDocumento(rs.getString(++j));
                vo.setDTipoDocumento(rs.getString(++j));
                list.add(vo);
            }

            procedure.close();
            conn.close();

        } catch (SQLException e1) {
                throw new TransactionException(e1);
        }
        return list;
    }
}